﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Helper.Infrastructure.Login;
using Helper.Infrastructure.Session;

namespace Helper.Controllers
{
    public class BaseController : Controller
    {
        public bool LoginNeeded
        {
            get;
            set;
        }

        protected override void ExecuteCore()
        {
            if (!SessionAuth.VerifySession(UserSession.GetInstance))
                if (LoginNeeded)
                {
                    Response.Redirect(string.Format("{0}/Login/SecurityException", HttpContext.Request.Url.GetLeftPart(UriPartial.Authority)));
                    return;
                }

            base.ExecuteCore();                    
        }
    }
}